var gulp = require( 'gulp');
var ts = require( 'gulp-typescript');
var sourcemaps = require( 'gulp-sourcemaps');

var tsProject = ts.createProject( 'tsconfig.json');

gulp.task( 'ts-to-js', () => {
    return gulp.src( 'src/**/*.ts')
        .pipe( sourcemaps.init())
        .pipe( tsProject())
        .js
        .pipe( sourcemaps.write( '../maps'))
        .pipe( gulp.dest( 'dist'));
});

gulp.task( 'default', ['ts-to-js'], () => {
    gulp.watch( 'src/**/*.ts', ['ts-to-js']).on( 'change', event => {
        console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
    });
});